/**
 * 树有点权，P、D或者？
 * 要求对每一个？节点决定是P还是D，满足P、D不相邻
 * 二分图染色，做一个递归就行了
 * 都不用剪枝
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

using llt = long long;
using vi = vector<int>;
using vll = vector<llt>;
using pii = pair<int, int>;
using vpii = vector<pii>;

template<typename T>
void input(vector<T>&v, int n){
    v.assign(n + 1, {});
    for(int i=1;i<=n;++i)cin>>v[i];
    return;
}

int N;
vector<vi> G;
string S;

bool dfs(int u, int p){
    int t = 0;
    for(auto v : G[u]){
        if(v == p) continue;

        if((S[v] ^ S[u]) == 0) return false;

        if(S[v] != '?'){
            bool flag = dfs(v, u);
            if(not flag) return false;
        }else{
            S[v] = S[u] ^ 'p' ^ 'd';
            bool flag = dfs(v, u);            
            if(not flag) return false;            
        }     
    }
    return true;
}

void work(){
    cin >> N >> S;
    S = " " + S;
    G.assign(N + 1, {});
    for(int a,b,i=1;i<N;++i){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    if(S[1] != '?'){
        if(not dfs(1, 0)) return (void)(cout << "-1\n");
    }else{
        S[1] = 'd';
        bool flag = dfs(1, 0);
        if(not flag){
            S[1] = 'p';
            flag = dfs(1, 0);
            if(not flag) return (void)(cout << "-1\n");
        }
    }
    cout << S.substr(1) << endl;
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) {
		work();
	}
    return 0;
}